package com.heliming.data.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.heliming.data.entity.User;
import com.heliming.data.mapper.WriterMapper;
import com.heliming.data.service.WriterService;
import com.heliming.data.utils.BaseServiceImpl;
import com.heliming.data.utils.BizCode;
import com.heliming.data.utils.BizException;
import com.heliming.data.utils.CommonUtils;

@Service
@Transactional(rollbackFor=Exception.class)
public class WriterServiceImpl extends BaseServiceImpl implements WriterService {
	
	@Autowired
	private WriterMapper writerMapper;

	@Override
	public String insert(User user) {
		user.changeStatus(CommonUtils.METHOD_ADD, getUserName());
		int num = writerMapper.insertUser(user);
		if(num < 0){
			throw new BizException(BizCode.FAILD_ADD_EXCEPTION);
		}
		return user.getId();
	}
	
	

}
